#include "plbtLuaBindings.h"
#include "plBullet.h"

RegisterCustomDatatype<plbtBodyBind> g_btBody_dt("PlRigidBody");
RegisterCustomDatatype<plbtConstrBind> g_btConstr_dt("PlConstraint");
RegisterCustomDatatype<plbtShapeBind> g_btShape_dt("PlShape");

static int li_delete_bodybind(lua_State* L)
{
	GeneroRef<PlRigidBody>* ref = pop_custom<GeneroRef<PlRigidBody>>(L, 1, "PlRigidBody");
	delete ref;
	return 0;
}

static int li_delete_constrbind(lua_State* L)
{
	GeneroRef<PlConstraint>* ref = pop_custom<GeneroRef<PlConstraint>>(L, 1, "PlConstraint");
	delete ref;
	return 0;
}

static int li_delete_shapebind(lua_State* L)
{
	GeneroRef<PlShape>* ref = pop_custom<GeneroRef<PlShape>>(L, 1, "PlShape");
	delete ref;
	return 0;
}

void plbtBodyBind::registerFunctions(lua_State* L)
{
	plbtBodyBind::pushStaticFuncs(L);
}

void plbtConstrBind::registerFunctions(lua_State* L)
{
	plbtConstrBind::pushStaticFuncs(L);
}

void plbtShapeBind::registerFunctions(lua_State* L)
{
	plbtShapeBind::pushStaticFuncs(L);
}

void plbtBodyBind::pushStaticFuncs(lua_State* L)
{
	static const struct luaL_Reg mylib [] = {
		{"GetSlotId", li_getSlotId},
		{"SetShape", li_setShape},
		{"AddToWorld", li_addToWorld},
		{"RemoveFromWorld", li_removeFromWorld},
		{"SetMass", li_setMass},
		{"SetInertia", li_setInertia},
		{"SetPosition", li_setPosition},
		{"SetRotation", li_setRotation},
		{"SetLinearVelocity", li_setLinearVelocity},
		{"SetAngularVelocity", li_setAngularVelocity},
		{"GetPosition", li_getPosition},
		{"GetRotation", li_getRotation},
		{"GetLinearVelocity", li_getLinearVelocity},
		{"GetAngularVelocity", li_getAngularVelocity},
		{"ApplyGlobalForce", li_applyGlobalForce},
		{"ApplyLocalForce", li_applyLocalForce},
		{"ApplyGlobalTorque", li_applyGlobalTorque},
		{"ApplyLocalTorque", li_applyLocalTorque},
		{"LocalPosToWorld", li_localPosToWorld},
		{"WorldPosToLocal", li_worldPosToLocal},
		{"LocalVecToWorld", li_localVecToWorld},
		{"WorldVecToLocal", li_worldVecToLocal},
		{"AutoCalcInertia", li_autoCalcInertia},
		{"FinalizeBody", li_finalizeBody},
		{"InWorld", li_inWorld},
		{"__gc", li_delete_bodybind},
		{NULL, NULL}  /* sentinel */
	};

	// dump them into said table
	luaL_register(L, NULL, mylib);
}

void plbtConstrBind::pushStaticFuncs(lua_State* L)
{
	static const struct luaL_Reg mylib [] = {
		{"AddToWorld", li_addToWorld},
		{"RemoveFromWorld", li_removeFromWorld},
		{"SetVector", li_setVector},
		{"SetQuaternion", li_setQuaternion},
		{"AddBody", li_addBody},
		{"AllowCollisions", li_allowCollisions},
		{"SetMotor", li_setMotor},
		{"DisableMotor", li_disableMotor},
		{"SetLimits", li_setLimits},
		{"NumMotors", li_numMotors},
		{"CreateHinge", li_createHinge},
		{"CreateP2P", li_createP2P},
		{"CreateSlider", li_createSlider},
		{"CreateConeTwist", li_createConeTwist},
		{"__gc", li_delete_constrbind},
		{NULL, NULL}  /* sentinel */
	};

	// dump them into said table
	luaL_register(L, NULL, mylib);
}

void plbtShapeBind::pushStaticFuncs(lua_State* L)
{
	static const struct luaL_Reg mylib [] = {
		{"GetRefCt", li_getRefCt},
		{"Finalize", li_finalize},
		{"CreateBoxShape", li_createBoxShape},
		{"CreateSphereShape", li_createSphereShape},
		{"CreateCylinderShape", li_createCylinderShape},
		{"CreateCapsuleShape", li_createCapsuleShape},
		{"CreateConeShape", li_createConeShape},
		{"CreateCompoundShape", li_createCompoundShape},
		{"AddSubShape", li_addSubShape},
		{"__gc", li_delete_shapebind},
		{NULL, NULL}  /* sentinel */
	};

	// dump them into said table
	luaL_register(L, NULL, mylib);
}

int plbtBodyBind::li_getSlotId(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int ret = op->getSlotId();
	lua_pushinteger(L, ret);
	return 1;
}


int plbtBodyBind::li_setShape(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	PlShape* a1 = pop_custom_reffed<PlShape>(L, 2, "PlShape"); if(a1 == NULL){ LOG(logERROR) << "Null input."; return 0; }
	op->setShape(a1);
	
	return 0;
}


int plbtBodyBind::li_addToWorld(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->addToWorld();
	
	return 0;
}


int plbtBodyBind::li_removeFromWorld(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->removeFromWorld();
	
	return 0;
}


int plbtBodyBind::li_setMass(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	double a1 = lua_tonumber(L, 2);
	op->setMass(a1);
	
	return 0;
}


int plbtBodyBind::li_setInertia(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	op->setInertia(a1);
	
	return 0;
}


int plbtBodyBind::li_setPosition(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	op->setPosition(a1);
	
	return 0;
}


int plbtBodyBind::li_setRotation(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btQuaternion* temp1 = pop_custom<btQuaternion>(L, 2, "btQuaternion"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btQuaternion& a1 = *temp1;
	op->setRotation(a1);
	
	return 0;
}


int plbtBodyBind::li_setLinearVelocity(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	op->setLinearVelocity(a1);
	
	return 0;
}


int plbtBodyBind::li_setAngularVelocity(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	op->setAngularVelocity(a1);
	
	return 0;
}


int plbtBodyBind::li_getPosition(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3 ret = op->getPosition();
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_getRotation(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btQuaternion ret = op->getRotation();
	push_custom<btQuaternion>(L, &ret, "btQuaternion");
	return 1;
}


int plbtBodyBind::li_getLinearVelocity(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3 ret = op->getLinearVelocity();
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_getAngularVelocity(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3 ret = op->getAngularVelocity();
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_applyGlobalForce(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	btVector3* temp2 = pop_custom<btVector3>(L, 3, "btVector3"); if(temp2 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a2 = *temp2;
	op->applyGlobalForce(a1, a2);
	
	return 0;
}


int plbtBodyBind::li_applyLocalForce(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	btVector3* temp2 = pop_custom<btVector3>(L, 3, "btVector3"); if(temp2 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a2 = *temp2;
	op->applyLocalForce(a1, a2);
	
	return 0;
}


int plbtBodyBind::li_applyGlobalTorque(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	op->applyGlobalTorque(a1);
	
	return 0;
}


int plbtBodyBind::li_applyLocalTorque(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	op->applyLocalTorque(a1);
	
	return 0;
}


int plbtBodyBind::li_localPosToWorld(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	btVector3 ret = op->localPosToWorld(a1);
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_worldPosToLocal(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	btVector3 ret = op->worldPosToLocal(a1);
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_localVecToWorld(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	btVector3 ret = op->localVecToWorld(a1);
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_worldVecToLocal(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	btVector3* temp1 = pop_custom<btVector3>(L, 2, "btVector3"); if(temp1 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a1 = *temp1;
	btVector3 ret = op->worldVecToLocal(a1);
	push_custom<btVector3>(L, &ret, "btVector3");
	return 1;
}


int plbtBodyBind::li_autoCalcInertia(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->autoCalcInertia();
	
	return 0;
}


int plbtBodyBind::li_finalizeBody(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->finalizeBody();
	
	return 0;
}


int plbtBodyBind::li_inWorld(lua_State* L)
{
	PlRigidBody* op = pop_custom_reffed<PlRigidBody>(L, 1, "PlRigidBody");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	bool ret = op->inWorld();
	lua_pushboolean(L, ret);
	return 1;
}

int plbtConstrBind::li_addToWorld(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->addToWorld();
	
	return 0;
}


int plbtConstrBind::li_removeFromWorld(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->removeFromWorld();
	
	return 0;
}


int plbtConstrBind::li_setVector(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int a1 = (int)lua_tointeger(L, 2);
	btVector3* temp2 = pop_custom<btVector3>(L, 3, "btVector3"); if(temp2 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a2 = *temp2;
	op->setVector(a1, a2);
	
	return 0;
}


int plbtConstrBind::li_setQuaternion(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int a1 = (int)lua_tointeger(L, 2);
	btQuaternion* temp2 = pop_custom<btQuaternion>(L, 3, "btQuaternion"); if(temp2 == NULL){ LOG(logERROR) << "Null input."; return 0; } btQuaternion& a2 = *temp2;
	op->setQuaternion(a1, a2);
	
	return 0;
}


int plbtConstrBind::li_addBody(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int a1 = (int)lua_tointeger(L, 2);
	PlRigidBody* a2 = pop_custom_reffed<PlRigidBody>(L, 3, "PlRigidBody"); if(a2 == NULL){ LOG(logERROR) << "Null input."; return 0; }
	op->addBody(a1, a2);
	
	return 0;
}


int plbtConstrBind::li_allowCollisions(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	bool a1 = (lua_toboolean(L, 2) > 0);
	op->allowCollisions(a1);
	
	return 0;
}


int plbtConstrBind::li_setMotor(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int a1 = (int)lua_tointeger(L, 2);
	float a2 = (float)lua_tonumber(L, 3);
	float a3 = (float)lua_tonumber(L, 4);
	op->setMotor(a1, a2, a3);
	
	return 0;
}


int plbtConstrBind::li_disableMotor(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int a1 = (int)lua_tointeger(L, 2);
	op->disableMotor(a1);
	
	return 0;
}


int plbtConstrBind::li_setLimits(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int a1 = (int)lua_tointeger(L, 2);
	float a2 = (float)lua_tonumber(L, 3);
	float a3 = (float)lua_tonumber(L, 4);
	op->setLimits(a1, a2, a3);
	
	return 0;
}


int plbtConstrBind::li_numMotors(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int ret = op->numMotors();
	lua_pushinteger(L, ret);
	return 1;
}


int plbtConstrBind::li_createHinge(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->createHinge();
	
	return 0;
}


int plbtConstrBind::li_createP2P(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->createP2P();
	
	return 0;
}


int plbtConstrBind::li_createSlider(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->createSlider();
	
	return 0;
}


int plbtConstrBind::li_createConeTwist(lua_State* L)
{
	PlConstraint* op = pop_custom_reffed<PlConstraint>(L, 1, "PlConstraint");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->createConeTwist();
	
	return 0;
}

int plbtShapeBind::li_getRefCt(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	int ret = op->getRefCt();
	lua_pushinteger(L, ret);
	return 1;
}


int plbtShapeBind::li_finalize(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->finalize();
	
	return 0;
}


int plbtShapeBind::li_createBoxShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	double a1 = (double)lua_tonumber(L, 2);
	double a2 = (double)lua_tonumber(L, 3);
	double a3 = (double)lua_tonumber(L, 4);
	op->createBoxShape(a1, a2, a3);
	
	return 0;
}


int plbtShapeBind::li_createSphereShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	double a1 = (double)lua_tonumber(L, 2);
	op->createSphereShape(a1);
	
	return 0;
}


int plbtShapeBind::li_createCylinderShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	double a1 = (double)lua_tonumber(L, 2);
	double a2 = (double)lua_tonumber(L, 3);
	double a3 = (double)lua_tonumber(L, 4);
	op->createCylinderShape(a1, a2, a3);
	
	return 0;
}


int plbtShapeBind::li_createCapsuleShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	double a1 = (double)lua_tonumber(L, 2);
	double a2 = (double)lua_tonumber(L, 3);
	op->createCapsuleShape(a1, a2);
	
	return 0;
}


int plbtShapeBind::li_createConeShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	double a1 = (double)lua_tonumber(L, 2);
	double a2 = (double)lua_tonumber(L, 3);
	op->createConeShape(a1, a2);
	
	return 0;
}


int plbtShapeBind::li_createCompoundShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	op->createCompoundShape();
	
	return 0;
}


int plbtShapeBind::li_addSubShape(lua_State* L)
{
	PlShape* op = pop_custom_reffed<PlShape>(L, 1, "PlShape");
	if(op == NULL){
		LOG(logERROR) << "Null self!";
	return 0;}
	PlShape* a1 = pop_custom_reffed<PlShape>(L, 2, "PlShape"); if(a1 == NULL){ LOG(logERROR) << "Null input."; return 0; }
	btVector3* temp2 = pop_custom<btVector3>(L, 3, "btVector3"); if(temp2 == NULL){ LOG(logERROR) << "Null input."; return 0; } btVector3& a2 = *temp2;
	btQuaternion* temp3 = pop_custom<btQuaternion>(L, 4, "btQuaternion"); if(temp3 == NULL){ LOG(logERROR) << "Null input."; return 0; } btQuaternion& a3 = *temp3;
	float a4 = (float)lua_tonumber(L, 5);
	op->addSubShape(a1, a2, a3, a4);
	
	return 0;
}
